package com.vhall.component.controller.filter;

import com.vhall.component.controller.filter.facade.FilterWordsApiFacade;
import com.vhall.component.entity.filter.vo.FilterWordsGetReqVO;
import com.vhall.component.entity.filter.vo.FilterWordsReportReqVO;
import com.vhall.component.framework.common.annotation.VhallComponent;
import com.vhall.component.framework.common.exception.BusinessException;
import com.vhall.component.plugin.common.annotation.ApiSignatureAuth;
import com.vhall.component.plugin.common.annotation.TokenAuth;
import com.vhall.component.plugin.common.exception.BizErrorCode;
import com.vhall.component.plugin.common.support.Token;
import com.vhall.component.plugin.common.support.TokenThreadLocal;
import com.vhall.component.service.filter.FilterWordsApiService;
import org.springframework.beans.factory.annotation.Autowired;


/**
 * @author longzhen.gong
 * @date 2021/7/2 14:42
 */
@VhallComponent
@ApiSignatureAuth
@TokenAuth
public class FilterWordsApiController implements FilterWordsApiFacade {

    @Autowired
    private FilterWordsApiService filterWordsApiService;


    /**
     * 获取敏感词
     *
     * @param vo
     * @return
     */
    @Override
    public String getFilterWords(FilterWordsGetReqVO vo) {
        return filterWordsApiService.getFilterWords(vo);
    }

    @Override
    public Boolean reportFilterWords(FilterWordsReportReqVO reqVO) {
        Token token = TokenThreadLocal.getToken();
        Integer accountId = token.getAccountId();
        if (accountId == null) {
            throw new BusinessException(BizErrorCode.AUTH_LOGIN_NEEDS);
        }
        return filterWordsApiService.reportFilterWords(reqVO, accountId);
    }
}
